//
//  WSLoginContentView.m
//  FamilyLinkPro
//
//  Created by 江鹏 on 2023/9/4.
//  Copyright © 2023 SiterWell.Co.,Ltd. All rights reserved.
//

#import "WSLoginHomeContentView.h"

@implementation WSLoginHomeContentView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubviews];
    }
    return self;
}

// MARK: 添加子控件
- (void)setupSubviews {
    UIImageView *bgImageView = [[UIImageView alloc] initWithImage:ImageNamed(@"iv_guide_ground")];
    [self addSubview:bgImageView];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self).insets(UIEdgeInsetsZero);
    }];
    
    
    UIImageView *siterLogoView = [[UIImageView alloc] initWithImage:ImageNamed(@"logo")];
    [self addSubview:siterLogoView];
    [siterLogoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.centerY.mas_equalTo(self).offset(-120);
    }];
    
    UIButton *expressBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:expressBtn];
    [expressBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.left.mas_equalTo(self).offset(48);
        make.right.mas_equalTo(self).offset(-48);
        make.bottom.mas_equalTo(self).offset(-(BottomHeight + 37));
        make.height.offset(46);
    }];
    [expressBtn setTitle:@"立即体验" forState:UIControlStateNormal];
    [expressBtn setBackgroundColor:UIColorFromRGB_0x(0xFFFFFF)];
    ViewRadius(expressBtn, 20);
    [expressBtn setTitleColor:UIColorFromRGB_0x(0x666666) forState:UIControlStateNormal];
    expressBtn.titleLabel.font = fontBold(18);
    [expressBtn addTarget:self action:@selector(expressBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:loginBtn];
    [loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [loginBtn setBackgroundColor:UIColorFromRGB_0x(0x4C80F8)];
    ViewRadius(loginBtn, 20);
    [loginBtn setTitleColor:UIColorFromRGB_0x(0xFFFFFF) forState:UIControlStateNormal];
    loginBtn.titleLabel.font = fontBold(18);
    [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.left.mas_equalTo(self).offset(48);
        make.right.mas_equalTo(self).offset(-48);
        make.bottom.mas_equalTo(expressBtn.mas_top).offset(-25);
        make.height.offset(46);
    }];
    [loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    UIButton *regiserBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:regiserBtn];
    [regiserBtn setTitle:@"注册" forState:UIControlStateNormal];
    [regiserBtn setTitleColor:UIColorFromRGB_0x(0x333333) forState:UIControlStateNormal];
    regiserBtn.titleLabel.font = fontBold(16);
    [regiserBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).offset(StatusBarHeight + 44);
        make.right.mas_equalTo(self).offset(-14);
    }];
    [regiserBtn addTarget:self action:@selector(regiserBtnClick) forControlEvents:UIControlEventTouchUpInside];
    

}

// MARK: 按钮的响应事件

#pragma mark -- 立即体验

- (void)expressBtnClick {
    if (self.delegate && [self.delegate respondsToSelector:@selector(expressBtnClick)]) {
        [self.delegate expressBtnClick];
    }
}

#pragma mark -- 登录
- (void)loginBtnClick {
    if (self.delegate && [self.delegate respondsToSelector:@selector(loginBtnClick)]) {
        [self.delegate loginBtnClick];
    }
}

#pragma mark -- 注册
- (void)regiserBtnClick {
    if (self.delegate && [self.delegate respondsToSelector:@selector(regiserBtnClick)]) {
        [self.delegate regiserBtnClick];
    }
}

@end
